﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using AutoMapper;
using IStrong.EC.WebApi.Results.Entity.Daily;
using IStrong.EC.WebApi.Results.Entity.ViewModel;
using Senparc.Weixin.MP.AdvancedAPIs.OAuth;

namespace IStrong.EC.WebApi.Results.AutoMapperConfig
{
    public class AutoMapperConfigs : Profile
    {
        private readonly object dto;

        //添加你的实体映射关系.
        public AutoMapperConfigs()
        {
           CreateMap<OAuthUserInfo, Weixinusers>()
                //映射发生之前
                .BeforeMap((source, dto) => {
                    // 可以较为精确的控制输出数据格式
                    // dto.CreateTime = Convert.ToDateTime(source.CreateTime).ToString("yyyy-MM-dd");
                })
                //映射发生之后
                .AfterMap((source, dto) => {
                    //code ...
                });

            CreateMap<Dailyreports, DailyReportViewModel>()
                .ForMember(t => t.content, (s) => s.MapFrom(m => m.Dailycontent));
        }
    }
}
